package top.ljjapp.config;/**
 * @FileName: WebConfig.java
 * @Package: top.ljjapp.config
 * @Author: lijiajun
 * <br/>
 * @Created: 2018/11/21 11:11
 */

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import top.ljjapp.filter.TimeFilter;
import top.ljjapp.interceptor.TimeInterceptor;

import javax.servlet.FilterRegistration;
import java.util.ArrayList;
import java.util.List;

/**
 * <p></p>
 * <p/>
 * <PRE>
 * <BR> 修改记录
 * <BR>-----------------------------------------------
 * <BR> 修改日期 修改人 修改内容
 * </PRE>
 *
 * @author lijiajun
 */
//@Configuration
public class WebConfig extends WebMvcConfigurerAdapter {

    @Autowired
    private TimeInterceptor timeInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
//        registry.addInterceptor(timeInterceptor);
    }

    @Bean
    public FilterRegistrationBean timeFilter(){
        FilterRegistrationBean registrationBean = new FilterRegistrationBean();
        //将自定义的filter加入到过滤链中
        TimeFilter timeFilter = new TimeFilter();
//        registrationBean.setFilter(timeFilter);
        //定义过滤的url
        List<String> urls =  new ArrayList<>();
        urls.add("/*");
        registrationBean.setUrlPatterns(urls);

        return registrationBean;
    }

}